<template>
  <div class="content">
    <!-- 头部 -->
    <div class="game_header">
      <div class="left">
        <img src="/imgs/club/all_icon.png" alt="icon" class="icon" />
        <span class="text">{{ t('club_page_allfl') }}</span>
      </div>
      <div class="right">
        <span class="manage" v-if="props.isAdmin === 1 || props.isCreator === 1" @click="goToHandList">{{ t('club_page_sadmin') }}</span>
      </div>
    </div>

    <!-- 内容 -->
    <div class="game_grid">
      <div v-for="(game, index) in props.gameList" :key="index" class="game_card" >
        <div @click="goToClubHandList(game)">
          <div class="game_content">
            <img :src="game.game_icon" alt="" class="game_image" />
            <div class="badge" v-if="game.game_table_count > 0">{{ game.game_table_count }}</div>
          </div>
          <p class="game_title">{{ gameClubIds[game.game_type] }}</p>
        </div>
        <div class="overlay" v-if="game.game_lock_status === 0" @click="clickMask">
            <div class="lock_icon"></div>
            <div class="overlay_text">
              <p>{{ t('inside_page_game_coming_soon') }}</p>
              <p>{{ t('inside_page_game_stay_tuned') }}</p>
            </div>
          </div>
      </div>
    </div>
  </div>
</template>

<script setup lang="ts">
import {  ref } from 'vue';
import { useI18n } from "vue-i18n";
import { useRouter} from "vue-router";
import { showToast } from "@nutui/nutui";

const router = useRouter();
const { t } = useI18n();

const props: any =  defineProps({
  isAdmin: {
    type: Number,
    default: 0,
  },
  isCreator: {
    type: Number,
    default: 0,
  },
  clubId: {
    type: Number,
    default: 0,
  },
  gameList: {
    type: Array,
    required: true,
  }
});

const gameClubIds: any = ref({
  49: t('club_page_49'),
  47: t('club_page_47'),
})

const goToHandList = () => {
  router.push({
    path: '/club/handList', 
    query: { clubId: props.clubId } 
  })
}

const goToClubHandList = (game: any) => {
  router.push({ 
    path: "/club/clubHandList", 
    query: { gameType: game.game_type, clubId: props.clubId } 
  })
}

const clickMask = () => {
  showToast.text(t("not_open"))
}
</script>

<style scoped lang="scss">
.content {

  .game_header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 16px;
    margin-top: 16px;

    .left {
      display: flex;
      align-items: center;

      .icon {
        width: 16px;
        height: 16px;
        margin-right: 4px;
      }

      .text {
        font-size: 14px;
        color: #ffffff;
      }
    }

    .right{
      .manage {
        color: #5BD9FF;
        font-family: "PingFang SC";
        font-size: 14px;
        font-weight: 500;
      }
    }
  }

  .game_grid {
    width: 347px;
    margin: 16px auto;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    background-color: #0d0e21;

    .game_card {
      width: 106px;
      height: 140px;
      position: relative;
      text-align: center;
      color: white;
      padding-bottom: 12px;
      flex-direction: column;
      align-items: center;
      gap: 10px;
      border-radius: 8px;
      background: #1A1944;

      .game_content {
        // position: relative;
        width: 100%;
        height: 140px;
        padding-bottom: 125%;
        background: #1a1b35;
        border-radius: 8px;
        overflow: hidden;

        .game_image {
          position: absolute;
          top: 0;
          left: 0;
          width: 106px;
          height: 106px;
          object-fit: cover;
        }

        .badge {
          position: absolute;
          top: 0;
          right: 0;
          width: 22px;
          height: 16px;
          line-height: 16px;
          color: white;
          font-size: 12px;
          font-weight: bold;
          background: url("/imgs/club/badge.png") no-repeat center center;
          background-size: contain;
        }

        
      }
      .overlay {
          position: absolute;
          top: 0;
          left: 0;
          z-index: 99;
          width: 100%;
          height: 100%;
          background: rgba(0, 0, 0, 0.7);
          display: flex;
          flex-direction: column;
          justify-content: center;
          align-items: center;

          .lock_icon {
            width: 40px;
            height: 40px;
            background: url("/imgs/club/locked.png") no-repeat center center;
            background-size: contain;
            margin-bottom: 8px;
          }

          .overlay_text {
            text-align: center;
            color: #FFF;
            font-family: "PingFang SC";
            font-size: 12px;
            font-weight: 500;
          }
        }
      .game_title {
        position: absolute;
        bottom: 0px;
        left: 0px;
        width: 106px;
        height: 34px;
        font-size: 14px;
        line-height: 34px;
        text-align: center;
        border-radius: 0 0 8px 8px;
        background: #1A1944;
        color: #FFFFFF;
        font-family: "PingFang SC";
        font-weight: 500;
      }
    }
  }
}
</style>
